import request from "@/utils/request-mock";
import {
  StatusModel,
  OrderItemModel,
  OrderItemListModel,
  OrderInfoModel,
  OrderInfoListModel,
} from "@/types";
// 定义请求地址的枚举
enum Api {
  OrderInfoList = "/orderInfoList",
}
/**
 * 获取订单分页列表
 * @param pageNum当前页码 pageSize 每页条数
 * @returns 分页数据
 */
export const getOrderInfoListApi = (pageNum: number, pageSize: number) => {
  return request.get<OrderInfoListModel>(
    Api.OrderInfoList + `?_page=${pageNum}&_limit=${pageSize}`
  );
};

/**
 * 根据id删除订单
 * @param 订单id
 * @returns null
 */
export const deleteOrderInfoListApi = (id: number) => {
  return request.delete<null>(Api.OrderInfoList + `/${id}`);
};

/**
 * 新增订单数据
 * @param
 * @returns 新增的订单数据
 */
export const addOrderInfoListApi = () => {
  return request.post<OrderInfoModel>(Api.OrderInfoList);
};

/**
 * 根据id更新订单
 * @param 订单id
 * @returns 更新后的订单数据
 */
export const upDateOrderInfoListApi = (id: number) => {
  return request.put<OrderInfoModel>(Api.OrderInfoList + `/${id}`);
};
